//
//  HomeStrategyRightCell.m
//  GiftNote
//
//  Created by lanou on 15/8/17.
//  Copyright (c) 2015年 GN. All rights reserved.
//

#define kLeftGap 10
#define kGap 5

#import "HomeStrategyRightCell.h"
#import "HomeHeader.h"
#import "UIImageView+WebCache.h"

@interface HomeStrategyRightCell ()

@property (nonatomic, strong)NSMutableArray *imageArray;

@end

@implementation HomeStrategyRightCell

- (NSMutableArray *)imageArray
{
    if (_imageArray == nil) {
        self.imageArray = [NSMutableArray array];
    }
    return _imageArray;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        CGFloat bigWidth = (kHomeWidth - kLeftGap * 2 - kGap * 2) / 2;
        CGFloat smallWidth = (bigWidth - kGap) / 2;
        
        
        _bigImageView = [[UIImageView alloc]initWithFrame:CGRectMake(kLeftGap + kGap * 2 + smallWidth * 2, kLeftGap, bigWidth, bigWidth)];
        [self.contentView addSubview:_bigImageView];
        [self.imageArray addObject:_bigImageView];
        
        
        
        for (int i = 0; i < 4; i++) {
            int n = i % 2;
            int m = i / 2;
            
            _smallImageView = [[UIImageView alloc]initWithFrame:CGRectMake(kGap + (kGap + smallWidth) * n, kLeftGap + (kGap + smallWidth) * m, smallWidth, smallWidth)];
            [self.contentView addSubview:_smallImageView];
            [self.imageArray addObject:_smallImageView];
        }
        
    }
    return self;
}


- (void)setArray:(NSArray *)array
{
    _array = array;
    for (int i = 0; i < _array.count; i++) {
        UIImageView *imageView = self.imageArray[i];
        NSString *url = _array[i];
        [imageView sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:nil];
    }
}

@end

